﻿namespace EasyWeb.Design
{
    using System;

    [AttributeUsage(AttributeTargets.All)]
    public class EWDisplayNameAttribute : Attribute
    {
        private readonly EWLocalizableString name = new EWLocalizableString("Name");
        private readonly EWLocalizableString description = new EWLocalizableString("Description");
        private Type resourceType;

        public string Name
        {
            get { return this.name.Value; }
            set { this.name.Value = value; }
        }

        public string Description
        {
            get { return this.description.Value; }
            set { this.description.Value = value; }
        }

        public Type ResourceType
        {
            get { return this.resourceType; }
            set
            {
                if (this.resourceType != value)
                {
                    this.resourceType = value;
                    this.name.ResourceType = value;
                    this.description.ResourceType = value;
                }
            }
        }

        public string GetName()
        {
            return this.name.GetLocalizableValue();
        }

        public string GetDescription()
        {
            return this.description.GetLocalizableValue();
        }
    }
}
